// $codepro.audit.disable packageNamingConvention

/** Packages */
package edu.gatech.team404.tool;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * This class provides services related to scheduling.
 * @author Michael Dandy
 * @version 1.0
 */
public class Scheduler {
	/** Class tag for logging purpose */
	private final static String TAG = "Scheduler";
	
	public static Date getToday () {
		Calendar currentDate = Calendar.getInstance();
		return currentDate.getTime();
	}
		
	public static Date getNextWeek () {
		Calendar date = Calendar.getInstance();
		date.add(Calendar.DAY_OF_WEEK, 7);
		return date.getTime();
	}
	
	/**
	 * Convert Date to String. The string will be in this format:
	 * MM/DD/YYYY.
	 * @param date the date to be converted
	 * @return the converted date
	 */
	public static String convertToString (Date date) {
		SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy");
		return formatter.format(date);
	}
	
	/**
	 * Convert Date to String. The string will be in this format:
	 * MM/DD/YYYY.
	 * @param date the date to be converted
	 * @return the converted date
	 */
	public static Date convertToDate (String date) {
		DateFormat formatter = new SimpleDateFormat("MM/dd/yyyy");
		Date convertedDate = null;
		try {
			convertedDate = (Date) formatter.parse(date);
		} 
		catch (ParseException e) {
			Log.error(TAG, e);
		}
		return convertedDate;
	}
}
